unit mailview;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, RzButton, Vcl.ExtCtrls, RzPanel,
  Vcl.ImgList, Vcl.ComCtrls, RzListVw, Vcl.StdCtrls, Vcl.OleCtrls, SHDocVw_EWB,
  EwbCore, EmbeddedWB, Vcl.Buttons,MGlobal,uni;

type
  Tfrmmailview = class(TForm)
    il1: TImageList;
    rztlbr1: TRzToolbar;
    rztlbtn1: TRzToolButton;
    rztlbtn2: TRzToolButton;
    rztlbtn3: TRzToolButton;
    rztlbtn4: TRzToolButton;
    rztlbtn5: TRzToolButton;
    embdwb1: TEmbeddedWB;
    pnlatt: TPanel;
    lbl5: TLabel;
    shp3: TShape;
    lvatt: TRzListView;
    shp4: TShape;
    pnl4: TPanel;
    pnl2: TPanel;
    lbl4: TLabel;
    edtrq: TEdit;
    pnl1: TPanel;
    lbl2: TLabel;
    lblfrom: TLabel;
    pnl5: TPanel;
    edtsubject: TEdit;
    lblto: TLabel;
    procedure FormShow(Sender: TObject);
    procedure rztlbtn3Click(Sender: TObject);
  private
    { Private declarations }
    procedure CreateData;
  public
    { Public declarations }
    zh:string;
    nid:integer;
  end;

var
  frmmailview: Tfrmmailview;

implementation
uses
  main;

{$R *.dfm}

procedure Tfrmmailview.CreateData;
var
  query:TUniQuery;
  item:TListItem;
  ps:pstring;
begin
  query:=TUniQuery.Create(self);
  zhdic[zh].DB.GetSqlStrDataSet(query,'select * from mail_info where nid='+inttostr(nid),nil);
  if not query.Eof then
  begin
    edtsubject.Text:=query.FieldByName('subject').AsString;
    edtrq.Text:=query.FieldByName('sendtime').AsString;
    lblto.caption:=query.FieldByName('to').AsString;
    lblfrom.Caption:=query.FieldByName('from').AsString;
    embdwb1.HTMLCode.Clear;
    embdwb1.HTMLCode.Add(query.FieldByName('htmltext').AsString);

  end;
  zhdic[zh].DB.GetSqlStrDataSet(query,'select * from mail_att where infoid='+inttostr(nid),nil);
  while not query.Eof do
  begin
    item:=lvatt.items.add;
    item.Caption:=query.FieldByName('name').AsString;
    New(ps);
    ps^:=query.FieldByName('path').AsString;
    item.Data:=ps;
    query.Next;
  end;
  if lvatt.Items.Count>0 then
  lvatt.Visible:=True
  else
  lvatt.Visible:=false;
  FreeAndNil(query);
end;

procedure Tfrmmailview.FormShow(Sender: TObject);
begin
CreateData;
end;

procedure Tfrmmailview.rztlbtn3Click(Sender: TObject);
begin
  zhdic[zh].DB.SetSqlStrNonQuery('update mail_info set boxid=5 where nid='+inttostr(nid),nil);
  {
  zhdic[zh].DB.SetSqlStrNonQuery('delete from mail_att where infoid='+inttostr(nid),nil);
  zhdic[zh].DB.SetSqlStrNonQuery('delete from mail_detail where infoid='+inttostr(nid),nil);
  zhdic[zh].DB.SetSqlStrNonQuery('delete from mail_info where nid='+inttostr(nid),nil);
  }
end;

end.
